<?php namespace App\Http\Controllers;

use Azure;

class WelcomeController extends Controller {

	/*
	|--------------------------------------------------------------------------
	| Welcome Controller
	|--------------------------------------------------------------------------
	|
	| This controller renders the "marketing page" for the application and
	| is configured to only allow guests. Like most of the other sample
	| controllers, you are free to modify or remove it as you desire.
	|
	*/

	/**
	 * Create a new controller instance.
	 *
	 * @return void
	 */
	public function __construct()
	{
		$this->middleware('guest');
	}

	/**
	 * Show the application welcome screen to the user.
	 *
	 * @return Response
	 */
	public function index()
	{
		$connection ="DefaultEndpointsProtocol=https;AccountName=zeeshanshafiq;AccountKey=h/G62zxv9PVXShzyHjOket4rIfunnu8fNgAzxRQJei1Y22eUygmb/v1l/nyk6hTwLC8gCnsBRyjU1oWGwolSUg==";
		$blobRestProxy = Azure::getInstance()->createBlobService($connection);

		try {
			// List blobs.
			$blob_list = $blobRestProxy->listBlobs("fast");
			$blobs = $blob_list->getBlobs();

			foreach($blobs as $blob)
			{
				echo $blob->getName().": ".$blob->getUrl()."<br />";
			}
		}
		catch(ServiceException $e){
			// Handle exception based on error codes and messages.
			// Error codes and messages are here:
			// http://msdn.microsoft.com/library/azure/dd179439.aspx
			$code = $e->getCode();
			$error_message = $e->getMessage();
			echo $code.": ".$error_message."<br />";
		}

		return view('welcome');
	}

}
